﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace Simple_RCU
{
    public class LunabotOutputState
    {
        public enum ActionState { Off, Forward, Reverse };

        #region Variables
        /// <summary>
        /// Desired action of the collection bin
        /// </summary>
        public int collectionBin { get; set; }
        /// <summary>
        /// Desired action of the digging mechanism
        /// </summary>
        public int diggingMechanism { get; set; }
        /// <summary>
        /// Desired action of digging head
        /// </summary>
        public ActionState diggingHead { get; set; }
        /// <summary>
        /// Motor speed for both motors on the left side
        /// </summary>
        public int motorSpeedLeft { get; set; }
        /// <summary>
        /// Motor speed for both motors on the right side
        public int motorSpeedRight { get; set; }

        #endregion

        #region Constructor
        public LunabotOutputState()
        {
            // Set initial default values
            this.collectionBin = 1500;
            this.diggingMechanism = 1500;
            this.diggingHead = ActionState.Off;
            this.motorSpeedLeft = 0;
            this.motorSpeedRight = 0;
        }
        #endregion

        #region Methods
        public override bool Equals(System.Object obj)
        {
            /*return false if parameter is null*/
            if (obj == null)
                return false;

            /*if it can't be cast, return false*/
            LunabotOutputState state = obj as LunabotOutputState;
            if ((System.Object)state == null)
                return false;

            /*compare values*/
            return Equals(state);

        }

        public bool Equals(LunabotOutputState state)
        {
            if ((System.Object)state == null)
                return false;
            return (this.motorSpeedLeft == state.motorSpeedLeft) && (this.motorSpeedRight == state.motorSpeedRight)
                && (this.collectionBin == state.collectionBin) && (this.diggingMechanism == state.diggingMechanism)
                && (this.diggingHead == state.diggingHead);
        }

        /*including to maintain override requirements, although not used*/
        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * this.motorSpeedLeft.GetHashCode();
            hash = hash * this.motorSpeedRight.GetHashCode();
            hash = hash * this.collectionBin.GetHashCode();
            hash = hash * this.diggingMechanism.GetHashCode();
            hash = hash * this.diggingHead.GetHashCode();
            return hash;
        }
        #endregion

    }
}
